#include <stdio.h>
#include <stdlib.h>
//给你一个整数 columnNumber ，返回它在 Excel 表中相对应的列名称。

void reverse(char* str, int strSize) 
{
    int left = 0, right = strSize - 1;
    while (left < right) 
    {
        char tmp = str[left];
        str[left] = str[right], str[right] = tmp;
        left++;
        right--;
    }
}

char* convertToTitle(int columnNumber) 
{
    char *s = malloc(8);
    int count = 0;

    while(columnNumber > 0)
    {
        --columnNumber;
        s[count++] = columnNumber % 26 + 'A';
        columnNumber /= 26;
    }
    s[count] = '\0';
    reverse(s, count);
    return s;
}

int main()
{
    int n = 27;
    printf("%s\n",convertToTitle(n));
}